package copyengine.resource.resProxy
{
    /**
     *  用于描述需要Load的文件
     */
    public class CEResFIleDesc
    {
        //===============//
        //==  EXT 字段
        //===============//

        //在Atlas的CacheData中有两个文件文件需要加载,一个是纹理(atf/png),另外一个是xml结构的描述文件
        //因为Atlas继承自Texture 为了方便起见使用原本的filePath字段存储Texture路径,用该Key值定义的字段存储xml描述文件的路径
        public static const EXT_ATLAS_XML_FILE_PATH:String = "atlasPath";

        //缓存的二进制文件,如果不为空则优先从缓存中加载素材
        //Texture中仅仅用到EXT_CACHE_BYTE_A,TextureAtlas中同时缓存xml文件和Texture文件
        public static const EXT_CACHE_BYTE_A:String = "cacheByteA";
        public static const EXT_CACHE_BYTE_B:String = "cacheByteB";

        //Texture的扩展变量,用于指明当前文件是不是ATF
        public static const EXT_TEXTURE_IS_ATF:String = "isATF";

        //===============//
        //==  FILE TYPE 字段
        //===============//

        //Swf文件
        public static const FILE_TYPE_SWF:String = "swf";
        //单纹理
        public static const FILE_TYPE_TEXTURE:String = "texture";
        //Atlas的纹理
        public static const FILE_TYPE_ATLAS_TEXTURE:String = "atlas_texture";
        //CompressObject (通过ByteArray.compress压缩过后的对象)
        public static const FILE_TYPE_COMPRESSED_OBJ:String = "compressed_obj";
        //JSON
        public static const FILE_TYPE_JSON:String = "json";
        //XML
        public static const FILE_TYPE_XML:String = "xml";

        //===============//
        //== 公共属性
        //===============//

        public var fileName:String;
        public var fileSize:int = 1;
        public var filePath:String;
        public var fileType:String;

        //额外的附加数据,根据CacheData的类型不同解析方式不同
        public var extData:*;

        public function CEResFIleDesc()
        {
        }

        public function toString():String
        {
            return "file: " + fileName + " type: " + fileType + " path: " + filePath;
        }

        public function isHaveExtValue(_extKey:String):Boolean {return extData != null && extData[_extKey] != null;}

        public function getExtValue(_extKey:String):* {return extData[_extKey];}

    }
}
